<template>
  <el-dialog
    :title="params.title"
    :visible.sync="params.visible"
    width="460px"
    append-to-body
  >
    <pre style="white-space:pre-wrap">
      {{ str }}

    </pre>
    <!-- <dialog-btn /> -->
    <span slot="footer" class="dialog-footer">
      <el-button class="k_queding" @click="confirm">确 定</el-button>
    </span>
  </el-dialog>
</template>
<script>
export default {
  props: {
    params: {
      type: Object,
      default: () => {
        return {
          title: '信息', // 当前窗口标题
          visible: true, // 是否显示当前窗口
          driverID: '' // 传入的信息
        }
      }
    }
  },
  data() {
    return {
      str: []
    }
  },
  mounted() {
    this.initWindow()
  },
  methods: {
    initWindow() {
      this.str = []
      if (this.params.driverID === 'Ora') {
        this.str.push('/* Database 填写示例')
        this.str.push('ip:port:sid')
        this.str.push('ip:port/sname')
        this.str.push('oraname')
        this.str.push('*/')
        this.str.push('create user Core identified by 123456;')
        this.str.push('grant connect,resource to Core;')
        this.str.push('create user Detailed identified by 123456;')
        this.str.push('grant connect,resource to Detailed;')
        this.str.push('create user History identified by 123456;')
        this.str.push('grant connect,resource,create view to History;')
        this.str.push('create user Repository identified by 123456;')
        this.str.push('grant connect,resource to Repository;')
      } else if (this.params.driverID === 'MySQL') {
        this.str.push('CREATE DATABASE IF NOT EXISTS CoreDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;')
        this.str.push('CREATE DATABASE IF NOT EXISTS DetailedDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;')
        this.str.push('CREATE DATABASE IF NOT EXISTS HistoryDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;')
        this.str.push('CREATE DATABASE IF NOT EXISTS RepositoryDB DEFAULT CHARSET utf8 COLLATE utf8_general_ci;')
      } else if (this.params.driverID === 'PostgreSQL') {
        this.str.push("CREATE DATABASE coredb ENCODING = ''UTF8'';")
        this.str.push("CREATE DATABASE historydb ENCODING = ''UTF8'';")
        this.str.push("CREATE DATABASE repositorydb ENCODING = ''UTF8'';")
      } else {
        this.str.push('没有可用模板')
      }
      this.str = this.str.join('\r\n')
    },
    confirm() {
      this.params.confirm()
    }
  }
}
</script>
<style lang='scss' scoped>

</style>
